﻿using System.Data;
using System.IO;
using NHibernate.Tool.hbm2ddl;
using Configuration = NHibernate.Cfg.Configuration;

namespace ECommerce.Web.NHibernate
{
    public class SchemaExporter
    {
        private readonly Configuration configuration;

        public SchemaExporter(Configuration configuration)
        {
            this.configuration = configuration;
        }

        public void Export(IDbConnection connection)
        {
            var export = new SchemaExport(this.configuration);

            var outputToConsole = false;
            var exportSchemaToDatabase = true;
            var justDropSchema = false;
            TextWriter textWriter = null;

            export.Execute(outputToConsole, exportSchemaToDatabase, justDropSchema, connection, textWriter);
        }
    }
}
